import java.util.ArrayList;

/**
 * 
 * Parent class for all lists of data read into the Baphi Engine.
 *
 */
public class BaphiList {
	
	private ArrayList<BaphiListItem> list;
	
	/**
	 * Parent class for all lists of data read into the Baphi Engine.
	 */
	public BaphiList()
	{
		list = new ArrayList<BaphiListItem>();
	}
	
	/**
	 * Gets the number of objects in the list.
	 * @return size of list
	 */
	public int size()
	{
		return list.size();
	}

	/**
	 * Searches the list for an item with a specific name.
	 * @param name - name of object to be located
	 * @return object's index
	 */
	public int lookup(String name)
	{
		for (int i = 0; i < list.size(); i++)
			if (list.get(i).getName().equalsIgnoreCase(name))
				return i;
		
		return -1;
	}
	
	/**
	 * gets an object with the index number passed in.
	 * @param idx
	 * @return list item
	 */
	public BaphiListItem get(int idx)
	{
		return list.get(idx);
	}
	
	/**
	 * Adds an object to the list
	 * @param item
	 */
	public void add(BaphiListItem item)
	{
		list.add(item);
	}
}